package ch.ethz.fcl.metrobuzz.algorithm.network.shortest_path.public_transport;

import ch.ethz.fcl.metrobuzz.data.MBData;
import ch.ethz.fcl.metrobuzz.spatialindex.object2d.Point2D;

public class Walk {
	// assume walk speed 5 km/h
	public static final float SPEED = 5 / 3.6f;
	// assume real distance is 1.5 times the Euclidean distance
	private static final float REAL_DISTANCE_RATIO = 2.0f;

	// maximum walk limit set to 10 minutes
	public static final int MAXIMUM_WALK_LIMIT = 15 * 60;

	/**
	 * @param data
	 * @param p1
	 * @param p2
	 * @return time cost (in seconds) to walk between two points on the screen
	 */
	public static float walkCost(MBData data, Point2D p1, Point2D p2) {
		float distance = data.getScene().getBound().getWorldDist(p1, p2)
				* REAL_DISTANCE_RATIO;
		
		return distance / SPEED;
	}

	/**
	 * @param time
	 * @return distance that can be reached in certain time through walk
	 */
	public static float walkDistance(float time) {
		float distance = SPEED * time;
		return distance   / REAL_DISTANCE_RATIO;
	}

	/**
	 * @param data
	 * @param time
	 * @return screen length that can be reached in certain time through walk
	 */
	public static float getWalkScreenLength(MBData data, float time) {
		return data.getScene().getBound().getScreenDist(walkDistance(time));
	}
}
